﻿namespace SupportSystemDB
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// The Quotes Controller Class.
    /// </summary>
    public class QuoteController : ParentController
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="QuoteController"/> class.
        /// </summary>
        /// <param name="databaseAccess">The database access.</param>
        internal QuoteController( SupportEntities databaseAccess ) : base(databaseAccess)
        {
        }

        /// <summary>
        /// Adds the specified quote.
        /// </summary>
        /// <param name="quote">The quote.</param>
        /// <param name="memberId">The member id.</param>
        public void Add( string quote , int memberId )
        {
            this.SupportDB.AddQuote( quote , memberId );
        }

        /// <summary>
        /// Deletes the specified quote by id.
        /// </summary>
        /// <param name="quoteId">The quote id.</param>
        public void Delete( int quoteId )
        {
            this.SupportDB.DeleteQuote( quoteId );
        }

        /// <summary>
        /// Updates the specified quote by id.
        /// </summary>
        /// <param name="quoteId">The quote id.</param>
        /// <param name="newValue">The new value.</param>
        public void Update( int quoteId , string newValue )
        {
            this.SupportDB.EditQuote( newValue , quoteId );
        }

        /// <summary>
        /// Gets the random quote.
        /// </summary>
        /// <returns>A random quote</returns>
        public vQuote GetRandom()
        {
            return this.SupportDB.GetRandomQuote().FirstOrDefault();
        }

        /// <summary>
        /// Gets the member's Quotes .
        /// </summary>
        /// <param name="memberId">The member id.</param>
        /// <returns>List of Quotes</returns>
        public List<vQuote> GetMembers( int memberId )
        {
            return this.SupportDB.GetMemberQuotes( memberId ).ToList();
        }
    }
}
